home *** CD-ROM | disk | FTP | other *** search
- Frequently Asked Questions (FAQS);faqs.454
-
-
-
- State Symbol New Symbol New Symbol New
- Accept? State State State
-
- --> [0#0] Y 8:2 [0#3] 0:0 [0#0] 0 [A]
- [0#3] N 7:1 [3#3]
- [3#3] Y 1:7 [3#0] 9:9 [3#3] 9 [A]
- [3#0] N 2:8 [0#0]
- [A] Y
-
- for constant C=4, and
-
- State Symbol New Symbol New Symbol New
- Accept? State State State
-
- --> [0#0] Y 1:9 [0#8] 0:0 [0#0] 0 [A]
- [0#8] N 8:0 [8#8]
- [8#8] Y 0:8 [8#0] 9:9 [8#8] 9 [A]
- [8#0] N 9:1 [0#0]
- [A] Y
-
- for constant C=9, and the finite state machines for other constants
- accept only strings of zeroes. It is not hard to verify that the
- proposed regular expression (1) represents the union of the languages
- accepted by these machines, omitting the empty string and strings
- beginning with zero.
-
- I have written a computer program that constructs finite state
- machines for recognizing palintiples for various bases and constants.
- I found that base 10 is actually an unusually boring base for this
- problem. For instance, the machine for base 8, constant C=5 is
-
- State Symbol New Symbol New Symbol New
- Accept? State State State
-
- --> [0#0] Y 0:0 [0#0] 5:1 [0#3] 0 [A]
- [0#3] N 1:0 [1#1] 6:1 [1#4]
- [1#1] Y 0:1 [3#0] 5:2 [3#3]
- [3#0] N 1:5 [0#0] 6:6 [0#3] 6 [A]
- [3#3] Y 2:5 [1#1] 7:6 [1#4]
- [1#4] N 1:1 [4#1] 6:2 [4#4] 1 [A]
- [4#4] Y 2:6 [4#1] 7:7 [4#4] 7 [A]
- [4#1] N 1:6 [3#0] 6:7 [3#3]
- [A] Y
-
- for which I invite masochists to write the regular expression. If
- anyone wants more, I should remark that the base 29 machine for
- constant C=18 has 71 states!
-
- By the way, I did not find any way of predicting the size or form of
- the machines for the various bases, except that the machines for C=B-1
- all seem to be isomorphic to each other. If anyone investigates the
- general behavior, I would be most happy to hear about it.
-
- Dan Hoey
- Hoey@AIC.NRL.Navy.Mil
- May, 1992
- [ A preliminary version of this message appeared in April, 1991. ]
- ================================================================
- Dan
-
-
-
- ==> arithmetic/digits/power.two.p <==
- Prove that for any 9-digit number (base 10) there is an integral power
- of 2 whose first 9 digits are that number.
-
- ==> arithmetic/digits/power.two.s <==
- Let v = log to base 10 of 2.
- Then v is irrational.
-
- Let w = log to base 10 of these 9 digits.
-
- Since v is irrational, given epsilon > 0, there exists some natural number
- n such that
-
- {w} < {nv} < {w} + epsilon
-
- ({x} is the fractional part of x.) Let us pick n for when
-
- epsilon = log 1.00000000000000000000001.
-
- Then 2^n does the job.
-
- ==> arithmetic/digits/prime/101.p <==
- How many primes are in the sequence 101, 10101, 1010101, ...?
-
- ==> arithmetic/digits/prime/101.s <==
- Note that the sequence
- 101 , 10101, 1010101, ....
- can be viewed as
- 100**1 +1, 100**2 + 100**1 + 1, 100**3 + 100**2 + 100**1 +1 ....
- that is,
- the k-th term in the sequence is
- 100**k + 100**(k-1) + 100**(k-2) + ...+ 100**(1) + 1
- = (100)**(k+1) - 1
- ----------------
- 11 * 9
- = (10)**(2k+2) - 1
- ----------------
- 11 * 9
- = ((10)**(k+1) - 1)*((10)**(k+1) +1)
- ---------------------------------
- 11*9
- thus either 11 and 9 divide the numerator. Either they both divide the
- same factor in the numerator or different factors in the numerator. In
- any case, after dividing, they leave the numerators as a product of two
- integers. Only in the case of k = 1, one of the integers is 1. Thus
- there is exactly one prime in the above sequence: 101.
-
- ==> arithmetic/digits/prime/all.prefix.p <==
- What is the longest prime whose every proper prefix is a prime?
-
- ==> arithmetic/digits/prime/all.prefix.s <==
- 23399339, 29399999, 37337999, 59393339, 73939133
-
- ==> arithmetic/digits/prime/change.one.p <==
- What is the smallest number that cannot be made prime by changing a single
- digit? Are there infinitely many such numbers?
-
- ==> arithmetic/digits/prime/change.one.s <==
- 200. Obviously, you would have to change the last digit, but 201, 203,
- 207, and 209 are all composite. For any smaller number, you can change
- the last digit, and get
- 2,11,23,31,41,53,61,71,83,97,101,113,127,131,149,151,163,173,181, or 191.
-
- 200+2310n gives an infinite family, because changing the last
- digit to 1 or 7 gives a number divisible by 3; to 3, a number divisible
- by 7; to 9, a number divisible by 11.
-
- ==> arithmetic/digits/prime/prefix.one.p <==
- 2 is prime, but 12, 22, ..., 92 are not. Similarly, 5 is prime
- whereas 15, 25, ..., 95 are not. What is the next prime number
- which is composite when any digit is prefixed?
-
- ==> arithmetic/digits/prime/prefix.one.s <==
- 149
-
- ==> arithmetic/digits/reverse.p <==
- Is there an integer that has its digits reversed after dividing it by 2?
-
- ==> arithmetic/digits/reverse.s <==
- Assume there's such a positive integer x such that x/2=y and y is the
- reverse of x.
-
- Then x=2y. Let x = a...b, then y = b...a, and:
-
- b...a (y)
- x 2
- --------
- a...b (x)
-
- From the last digit b of x, we have b = 2a (mod 10), the possible
- values for b are 2, 4, 6, 8 and hence possible values for (a, b) are
- (1,2), (6,2), (2,4), (7,4), (3,6), (8,6), (4,8), (9,8).
-
- From the first digit a of x, we have a = 2b or a = 2b+1. None of the
- above pairs satisfy this condition. A contradiction.
-
- Hence there's no such integer.
-
- ==> arithmetic/digits/rotate.p <==
- Find integers where multiplying them by single digits rotates their digits.
-
- ==> arithmetic/digits/rotate.s <==
- 2 105263157894736842
- 3 1034482758620689655172413793
- 4 102564 153846 179487 205128 230769
- 5 142857 102040816326530612244897959183673469387755
- 6 1016949152542372881355932203389830508474576271186440677966
- 1186440677966101694915254237288135593220338983050847457627
- 1355932203389830508474576271186440677966101694915254237288
- 1525423728813559322033898305084745762711864406779661016949
- 7 1014492753623188405797 1159420289855072463768 1304347826086956521739
- 8 1012658227848 1139240506329
- 9 10112359550561797752808988764044943820224719
-
- In base B, suppose you have an N-digit answer A whose digits are
- rotated when multiplied by K. If D is the low-order digit of A, we
- have
-
- (A-D)/B + D B^(N-1) = K A .
-
- Solving this for A we have
-
- D (B^N - 1)
- A = ----------- .
- B K - 1
-
- In order for A >= B^(N-1) we must have D >= K. Now we have to find N
- such that B^N-1 is divisible by R=(BK-1)/gcd(BK-1,D). This always has
- a minimal solution N0(R,B)<R, and the set of all solutions is the set
- of multiples of N0(R,B). N0(R,B) is the length of the repeating part
- of the fraction 1/R in base B.
-
- N0(ST,B)=N0(S,B)N0(T,B) when (S,T)=1, and for prime powers, N0(P^X,B)
- divides (P-1)P^(X-1). Determining which divisor is a little more
- complicated but well-known (cf. Hardy & Wright).
-
- So given B and K, there is one minimal solution for each
- D=K,K+1,...,B-1, and you get all the solutions by taking repetitions
- of the minimal solutions.
-
- ==> arithmetic/digits/sesqui.p <==
- Find the least number where moving the first digit to the end multiplies by 1.5.
-
- Xref: bloom-picayune.mit.edu rec.puzzles:18138 news.answers:3070
- Newsgroups: rec.puzzles,news.answers
- Path: bloom-picayune.mit.edu!snorkelwacker.mit.edu!spool.mu.edu!uunet!questrel!chris
- From: uunet!questrel!chris (Chris Cole)
- Subject: rec.puzzles FAQ, part 3 of 15
- Message-ID: <puzzles-faq-3_717034101@questrel.com>
- Followup-To: rec.puzzles
- Summary: This posting contains a list of
- Frequently Asked Questions (and their answers).
- It should be read by anyone who wishes to
- post to the rec.puzzles newsgroup.
- Sender: chris@questrel.com (Chris Cole)
- Reply-To: uunet!questrel!faql-comment
- Organization: Questrel, Inc.
- References: <puzzles-faq-1_717034101@questrel.com>
- Date: Mon, 21 Sep 1992 00:08:46 GMT
- Approved: news-answers-request@MIT.Edu
- Expires: Sat, 3 Apr 1993 00:08:21 GMT
- Lines: 1353
-
- Archive-name: puzzles-faq/part03
- Last-modified: 1992/09/20
- Version: 3
-
- ==> arithmetic/digits/sesqui.s <==
- Let's represent this number as a*10^n+b, where 1<=a<=9 and
- b < 10^n. Then the condition to be satisfied is:
-
- 3/2(a*10^n+b) = 10b+a
-
- 3(a*10^n+b) = 20b+2a
-
- 3a*10^n+3b = 20b+2a
-
- (3*10^n-2)a = 17b
-
- b = a*(3*10^n-2)/17
-
- So we must have 3*10^n-2 = 0 (mod 17) (since a is less than 10, it
- cannot contribute the needed prime 17 to the factorization of 17b).
- (Also, assuming large n, we must have a at most 5 so that b < 10^n will
- be satisfied, but note that we can choose a=1). Now,
-
- 3*10^n-2 = 0 (mod 17)
-
- 3*10^n = 2 (mod 17)
-
- 10^n = 12 (mod 17)
-
- A quick check shows that the smallest n which satisfies this is 15
- (the fact that one exists was assured to us because 17 is prime). So,
- setting n=15 and a=1 (obviously) gives us b=176470588235294, so the
- number we are looking for is
-
- 1176470588235294
-
- and, by the way, we can set a=2 to give us the second smallest such
- number,
- 2352941176470588
-
- Other things we can infer about these numbers is that there are 5 of
- them less than 10^16, 5 more less than 10^33, etc.
-
- ==> arithmetic/digits/squares/leading.7.to.8.p <==
- What is the smallest square with leading digit 7 which remains a square
- when leading 7 is replaced by an 8?
-
- ==> arithmetic/digits/squares/leading.7.to.8.s <==
- x=2996282391593370361328125
- y=2824483699753370361328125
- x^2=8977708170172487211329625006796419620513916015625
- y^2=7977708170172487211329625006796419620513916015625
-
- ==> arithmetic/digits/squares/length.22.p <==
- Is it possible to form two numbers A and B from 22 digits such that
- A = B^2? Of course, leading digits must be non-zero.
-
- ==> arithmetic/digits/squares/length.22.s <==
- No, the number of digits of A^2 must be of the form 3n or 3n-1.
-
- ==> arithmetic/digits/squares/length.9.p <==
- Is it possible to make a number and its square, using the digits from 1 through
- 9 exactly once?
-
- ==> arithmetic/digits/squares/length.9.s <==
- 567 and 854.
-
- ==> arithmetic/digits/squares/three.digits.p <==
- What squares consist entirely of three digits (e.g., 1, 4, and 9)?
-
- ==> arithmetic/digits/squares/three.digits.s <==
- The full set of solutions up to 10**12 is
- 1 -> 1
- 2 -> 4
- 3 -> 9
- 7 -> 49
- 12 -> 144
- 21 -> 441
- 38 -> 1444
- 107 -> 11449
- 212 -> 44944
- 31488 -> 9914 94144
- 70107 -> 49149 91449
- 3 87288 -> 14 99919 94944
- 956 10729 -> 9 14141 14499 11441
- 4466 53271 -> 199 49914 44949 99441
- 31487 17107 -> 9914 41941 99144 49449
- 2 10810 79479 -> 4 44411 91199 99149 11441
-
- If the algorithm is used in the form I presented it before, generating
- the whole set P_n before starting on P_{n+1}, the store requirements
- begin to become embarassing. For n>8 I switched to a depth-first
- strategy, generating all the elements in P_i (i=9..12) congruent to
- a particular x in P_8 for each x in turn. This means the solutions
- don't come out in any particular order, of course. CPU time was 16.2
- seconds (IBM 3084).
-
- In article <1990Feb6.025205.28153@sun.soe.clarkson.edu>, Steven
- Stadnicki suggests alternate triples of digits, in particular {1,4,6}
- (with many solutions) and {2,4,8} (with few). I ran my program on
- these as well, up to 10**12 again:
- 1 -> 1
- 2 -> 4
- 4 -> 16
- 8 -> 64
- 12 -> 144
- 21 -> 441
- 38 -> 1444
- 108 -> 11664
- 119 -> 14161
- 121 -> 14641
- 129 -> 16641
- 204 -> 41616
- 408 -> 1 66464
- 804 -> 6 46416
- 2538 -> 64 41444
- 3408 -> 116 14464
- 6642 -> 441 16164
- 12908 -> 1666 16464
- 25771 -> 6641 44441
- 78196 -> 61146 14416
- 81619 -> 66616 61161
- 3 33858 -> 11 14611 64164
- 2040 00408 -> 41 61616 64641 66464
- 6681 64962 -> 446 44441 64444 61444
- 8131 18358 -> 661 16146 41166 16164
- 40182 85038 -> 16146 61464 66146 61444 (Steven's last soln.)
- 1 20068 50738 -> 1 44164 46464 46111 44644
- 1 26941 38988 -> 1 61141 16464 66616 64144
- 1 27069 43631 -> 1 61466 41644 14114 64161
- 4 01822 24262 -> 16 14611 14664 16614 44644
- 4 05784 63021 -> 16 46611 66114 66644 46441
- 78 51539 12392 -> 6164 66666 14446 44111 61664
- and
- 2 -> 4
- 22 -> 484
- 168 -> 28224
- 478 -> 2 28484
- 2878 -> 82 82884 (Steven's last soln.)
- 2109 12978 -> 44 48428 42888 28484
- (so the answer to Steven's "Are there any more at all?" is "Yes".)
-
- The CPU times were 42.9 seconds for {1,4,6}, 18.7 for {2,4,8}. This
- corresponds to an interesting point: the abundance of solutions for
- {1,4,6} is associated with abnormally large sets P_n (|P_8| = 16088
- for {1,4,6} compared to |P_8| = 5904 for {1,4,9}) but the deficiency
- of solutions for {2,4,8} is *not* associated with small P_n's (|P_8|
- = 6816 for {2,4,8}). Can anyone wave a hand convincingly to explain
- why the solutions for {2,4,8} are so sparse?
-
- I suspect we are now getting to the point where an improved algorithm
- is called for. The time to determine all the n-digit solutions (i.e.
- 2n-digit squares) using this last-significant-digit-first is essentially
- constant * 3**n. Dean Hickerson in <90036.134503HUL@PSUVM.BITNET>, and
- Ilan Vardi in <1990Feb5.214249.22811@Neon.Stanford.EDU>, suggest using
- a most-significant-digit-first strategy, based on the fact that the
- first n digits of the square determine the (integral) square root; this
- also has a running time constant * 3**n. Can one attack both ends at
- once and do better?
-
- Chris Thompson
- JANET: cet1@uk.ac.cam.phx
- Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk
-
- Hey guys, what about
-
- 648070211589107021 ^ 2 = 419994999149149944149149944191494441
-
- This was found by David Applegate and myself (about 5 minutes on a DEC 3100,
- program in C).
-
- This is the largest square less than 10^42 with the 149-property; checking
- took a bit more than an hour of CPU time.
-
- As somebody suggested, we used a combined most-significant/least-significant
- digits attack. First we make a table of p-digit prefixes (most significant
- p digits) that could begin a root whose square has the 149 property in its
- first p digits. We organize this table into buckets by the least
- significant q digits of the prefixes. Then we enumerate the s digit
- suffixes whose squares have the 149 property in their last s digits. For
- each such suffix, we look in the table for those prefixes whose last q
- digits match the first q of the suffix. For each match, we consider the p +
- s - q digit number formed by overlapping the prefix and the suffix by q
- digits. The squares of these overlap numbers must contain all the squares
- with the 149 property.
-
- The time expended is O(3^p) to generate the prefix table, O(3^s) to
- enumerate the suffixes, and O(3^(p+s) / 10^q) to check the overlaps (being
- very rough and ignoring the polynomial factors) By judiciously chosing p, q,
- and s, we can fix things so that each bucket of the table has around O(1)
- entries: set q = p log10(3). Setting p = s, we end up looking for squares
- whose roots have n = 2 - log10(3) digits, with an algorithm that takes time
- O( 3 ^ [n / (2 - log10(3)]) ), roughly time O(3^[.66n]). Compared to the
- O(3^n) performance of either single-ended algorithm, this lets us check 50%
- more digits in the same amount of time (ignoring polynomial factors). Of
- course, the space cost of the combined-ends method is high.
-
- -- Guy and Dave
- --
- Guy Jacobson School of Computer Science
- Carnegie Mellon arpanet : guy@cs.cmu.edu
- Pittsburgh, PA 15213 csnet : Guy.Jacobson%a.cs.cmu.edu@csnet-relay
- (412) 268-3056 uucp : ...!{seismo, ucbvax, harvard}!cs.cmu.edu!guy
-
- Here is an algorithm which takes O(sqrt(n)log(n)) steps to find all perfect
- squares < n whose only digits are 1, 4 and 9.
-
- This doesn't sound too great *but* it doesn't use a lot of memory and only
- requires addition and <. Also, the actual run time will depend on where the
- first non-{1,4,9} digit appears in each square.
-
- set n = 1
- set odd = 1
-
- while(n < MAXVAL)
- {
- if(all digits of n are in {1,4,9})
- {
- print n
- }
-
- add 2 to odd
- add odd to n
- }
-
- This works because (X+1)^2 - x^2 = 2x+1.
- That is, if you start with 0 and add successive odd
- numbers to it you get 0+1=1, 1+3=4, 4+5=9, 9+7=16 etc.
- I've started the algorithm at 1 for convenience.
-
- The "O" value comes from looking at at most all digits
- (log(n)) of all perfect squares < n (sqrt(n) of them)
- at most a constant number of times.
-
- I didn't save the articles with algorithms claiming to be
- O(3^log(n)) so I don't know if their calculations needed
- to (or did) account for multiplication or sqrt() of large
- numbers. O(3^log(n)) sounds reasonable so I'm going to
- assume they did unless I hear otherwise.
-
- Any comments? Please email if you just want to refresh my memory
- on the other algorithms.
-
- Andrew Charles
- acgd@ihuxy.ATT.COMM
-
- ==> arithmetic/digits/squares/twin.p <==
- Let a twin be a number formed by writing the same number twice,
- for instance, 81708170 or 132132. What is the smallest square twin?
-
- ==> arithmetic/digits/squares/twin.s <==
- 1322314049613223140496 = 36363636364 ^ 2.
-
- The key to solving this puzzle is looking at the basic form of these
- "twin" numbers, which is some number k = 1 + 10^n multiplied by some number
- a < 10^n. If ak is a perfect square, k must have some repeated factor,
- since a<k. Searching the possible values of k for one with a repeated factor
- eventually turns up the number 1 + 10^11 = 11^2 * 826446281.
- So, we set a=826446281 and ak = 9090909091^2 = 82644628100826446281,
- but this needs leading zeros to fit the pattern. So, we multiply by a suitable
- small square (in this case 16) to get the above answer.
-
- ==> arithmetic/digits/sum.of.digits.p <==
- Find sod ( sod ( sod (4444 ^ 4444 ) ) ).
-
- ==> arithmetic/digits/sum.of.digits.s <==
- let X = 4444^4444
-
- sod(X) <= 9 * (# of digits) < 145900
- sod(sod(X)) <= sod(99999) = 45
- sod(sod(sod(X))) <= sod(39) = 12
-
- but sod(sod(sod(X))) = 7 (mod 9)
-
- thus sod(sod(sod(X))) = 7
-
- ==> arithmetic/digits/zeros/factorial.p <==
- How many zeros are in the decimal expansion of n!?
-
- ==> arithmetic/digits/zeros/factorial.s <==
- The general answer to the question
- "what power of p divides x!" where p is prime
- is (x-d)/(p-1) where d is the sum of the digits of (x written in base p).
-
- So where p=5, 10 is written as 20 and is divisible by 5^2 (2 = (10-2)/4);
- x to base 10: 100 1000 10000 100000 1000000
- x to base 5: 400 13000 310000 11200000 224000000
- d : 4 4 4 4 8
- trailing 0s in x! 24 249 2499 24999 249998
-
- ==> arithmetic/digits/zeros/lsd.factorial.p <==
- What is the least significant non-zero digit in the decimal expansion of n!?
-
- ==> arithmetic/digits/zeros/lsd.factorial.s <==
- Reduce mod 10 the numbers 2..n and then cancel out the
- required factors of 10. The final step then involves
- computing 2^i*3^j*7^k mod 10 for suitable i,j and k.
-
- A small program that performs this calculation is appended. Like the
- other solutions, it takes O(log n) arithmetic operations.
-
- -kym
- ===
-
- #include<stdio.h>
- #include<assert.h>
-
- int p[6][4]={
- /*2*/ 2, 4, 8, 6,
- /*3*/ 3, 9, 7, 1,
- /*4*/ 4, 6, 4, 6,
- /*5*/ 5, 5, 5, 5,
- /*6*/ 6, 6, 6, 6,
- /*7*/ 7, 9, 3, 1,
- };
-
- main(){
- int i;
- int n;
-
- for(n=2;n<1000;n++){
- i=lsdfact(n);
- printf("%d\n",i);
- }
-
- exit(0);
- }
-
- lsdfact(n){
- int a[10];
- int i;
- int n5;
- int tmp;
-
- for(i=0;i<=9;i++)a[i]=alpha(i,n);
-
- n5=0;
- /* NOTE: order is important in following */
- l5:;
- while(tmp=a[5]){ /* cancel factors of 5 */
- n5+=tmp;
- a[1]+=(tmp+4)/5;
- a[3]+=(tmp+3)/5;
- a[5]=(tmp+2)/5;
- a[7]+=(tmp+1)/5;
- a[9]+=(tmp+0)/5;
- }
- l10:;
- if(tmp=a[0]){
- a[0]=0; /* cancel all factors of 10 */
- for(i=0;i<=9;i++)a[i]+=alpha(i,tmp);
- }
- if(a[5]) goto l5;
- if(a[0]) goto l10;
-
- /* n5 == number of 5's cancelled;
- must now cancel same number of factors of 2 */
- i=ipow(2,a[2]+2*a[4]+a[6]+3*a[8]-n5)*
- ipow(3,a[3]+a[6]+2*a[9])*
- ipow(7,a[7]);
- assert(i%10); /* must not be zero */
- return i%10;
- }
-
- alpha(d,n){
- /* number of decimal numbers in [1,n] ending in digit d */
- int tmp;
- tmp=(n+10-d)/10;
- if(d==0)tmp--; /* forget 0 */
- return tmp;
- }
-
- ipow(x,y){
- /* x^y mod 10 */
- if(y==0) return 1;
- if(y==1) return x;
- return p[x-2][(y-1)%4];
- }
-
-
-
-
- ==> arithmetic/digits/zeros/million.p <==
- How many zeros occur in the numbers from 1 to 1,000,000?
-
- ==> arithmetic/digits/zeros/million.s <==
- In the numbers from 10^(n-1) through 10^n - 1, there are 9 * 10^(n-1)
- numbers of n digits each, so 9(n-1)10^(n-1) non-leading digits, of
- which one tenth, or 9(n-1)10^(n-2), are zeroes. When we change the
- range to 10^(n-1) + 1 through 10^n, we remove 10^(n-1) and put in
- 10^n, gaining one zero, so
-
- p(n) = p(n-1) + 9(n-1)10^(n-2) + 1 with p(1)=1.
-
- Solving the recurrence yields the closed form
-
- p(n) = n(10^(n-1)+1) - (10^n-1)/9.
-
- For n=6, there are 488,895 zeroes, 600,001 ones, and 600,000 of all other
- digits.
-
- ==> arithmetic/magic.squares.p <==
- Are there large squares, containing only consecutive integers, all of whose
- rows, columns and diagonals have the same sum? How about cubes?
-
- ==> arithmetic/magic.squares.s <==
- Here is an 8x8 example:
-
- 01 56 48 25 33 24 16 57
- 63 10 18 39 31 42 50 07
- 62 11 19 38 30 43 51 06
- 04 53 45 28 36 21 13 60
- 05 52 44 29 37 20 12 61
- 59 14 22 35 27 46 54 03
- 58 15 23 34 26 47 55 02
- 08 49 41 32 40 17 09 64
-
- References:
- "Magic Squares and Cubes"
- W.S. Andrews
- The Open Court Publishing Co.
- Chicago, 1908
-
- "Mathematical Recreations"
- M. Kraitchik
- Dover
- New York, 1953
-
-
-
-
- ==> arithmetic/pell.p <==
- Find integer solutions to x^2 - 92y^2 = 1.
-
- ==> arithmetic/pell.s <==
- x=1 y=0
- x=1151 y=120
- x=2649601 y=276240
- etc.
-
- Each successive solution is about 2300 times the previous
- solution; they are every 8th partial fraction (x=numerator,
- y=denominator) of the continued fraction for sqrt(92) =
- [9, 1,1,2,4,2,1,1,18, 1,1,2,4,2,1,1,18, 1,1,2,4,2,1,1,18, ...]
-
- Once you have the smallest positive solution (x1,y1) you
- don't need to "search" for the rest. You can obtain the nth positive
- solution (xn,yn) by the formula
-
- (x1 + y1 sqrt(92))^n = xn + yn sqrt(92).
-
- See Niven & Zuckerman's An Introduction to the Theory of Numbers.
- Look in the index under Pell's equation.
-
- ==> arithmetic/prime/arithmetic.progression.p <==
- Is there an arithmetic progression of 20 or more primes?
-
- ==> arithmetic/prime/arithmetic.progression.s <==
- There is an arithmetic progression of 21 primes:
- 142072321123 + 1419763024680 i, 0 <= i < 21.
-
- It was discovered on 30 November 1990, by programs running in the background
- on a network of Sun 3 workstations in the Department of Computer Science,
- University of Queensland, Australia.
-
- See: Andrew Moran and Paul Pritchard, The design of a background job
- on a local area network, Procs. 14th Australian Computer Science Conference,
- 1991, to appear.
-
- ==> arithmetic/prime/consecutive.composites.p <==
- Are there 10,000 consecutive non-prime numbers?
-
- ==> arithmetic/prime/consecutive.composites.s <==
- 9973!+2 through 9973!+10006 are composite.
-
- ==> arithmetic/sequence.p <==
- Prove that all sets of n integers contain a subset whose sum is divisible by n.
-
- ==> arithmetic/sequence.s <==
- Consider the set of remainders of the partial sums a(1) + ... + a(i).
- Since there are n such sums, either one has remainder zero (and we're
- thru) or 2 coincide, say the i'th and j'th. In this case, a(i+1) +
- ... + a(j) is divisible by n. (note this is a stronger result since
- the subsequence constructed is of *adjacent* terms.) Consider a(1)
- (mod n), a(1)+a(2) (mod n), ..., a(1)+...+a(n) (mod n). Either at
- some point we have a(1)+...+a(m) = 0 (mod n) or else by the pigeonhole
- principle some value (mod n) will have been duplicated. We win either
- way.
-
- ==> arithmetic/sum.of.cubes.p <==
- Find two fractions whose cubes total 6.
-
- ==> arithmetic/sum.of.cubes.s <==
- Restated:
- Find X, Y, minimum Z (all positive integers) where
- (X/Z)^3 + (Y/Z)^3 = 6
-
- Again, a generalized solution would be nice.
-
- You are asking for the smallest z s.t. x^3 + y^3 = 6*z^3 and x,y,z in Z+.
- In general, questions like these are extremely difficult; if you're
- interested take a look at books covering Diophantine equations
- (especially Baker's work on effective methods of computing solutions).
-
- Dudeney mentions this problem in connection with #20 in _The Canterbury
- Puzzles_; the smallest answer is (17/21)^3 + (37/21)^3 = 6.
-
- For the interest of the readers of this group I'll quote:
-
- "Given a known case for the expression of a number as the sum or
- difference of two cubes, we can, by formula, derive from it an infinite
- number of other cases alternately positive and negative. Thus Fermat,
- starting from the known case 1^3 + 2^3 = 9 (which we will call a
- fundamental case), first obtained a negative solution in bigger
- figures, and from this his positive solution in bigger figures still.
- But there is an infinite number of fundamentals, and I found by trial
- a negative fundamental solution in smaller figures than his derived
- negative solution, from which I obtained the result shown above. That
- is the simple explanation."
-
- In the above paragraph Dudeney is explaining how he derived (*by hand*)
- that (415280564497/348671682660)^3 + (676702467503/348671682660)^3 = 9.
-
- He continues:
-
- "We can say of any number up to 100 whether it is possible or not to
- express it as the sum of two cubes, except 66. Students should read
- the Introduction to Lucas's _Theorie des Nombres_, p. xxx."
-
- "Some years ago I published a solution for the case 6 = (17/21)^3 +
- (37/21)^3, of which Legendre gave at some length a 'proof' of
- impossibility; but I have since found that Lucas anticipated me in
- a communication to Sylvester."
-
- ==> arithmetic/tests.for.divisibility/eleven.p <==
- What is the test to see if a number is divisible by eleven?
-
-
- ==> arithmetic/tests.for.divisibility/eleven.s <==
- If the alternating sum of the digits is divisible by eleven, so is the number.
-
- For example, 1639 leads to 9 - 3 + 6 - 1 = 11, so 1639 is divisible by 11.
-
- Proof:
- Every integer n can be expressed as
- n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
- where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
- 10 is congruent to -1 mod(11).
- Thus if (-1^k)*a1 + (-1^k-1)*a2 + ...+ (a_k+1) is congruent to 0mod(11) then
- n is divisible by 11.
-
- ==> arithmetic/tests.for.divisibility/nine.p <==
- What is the test to see if a number is divisible by nine?
-
- ==> arithmetic/tests.for.divisibility/nine.s <==
- If the sum of the digits is divisible by nine, so is the number.
-
- Proof:
- Every integer n can be expressed as
- n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
- where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
- Note that 10 is congruent to 1 (mod 9). Thus 10^k is congruent to 1 (mod 9) for
- every k >= 0.
- Thus n is congruent to (a1+a2+a3+....+a_k+1) mod(9).
- Hence (a1+a2+...+a_k+1) is divisible by 9 iff n is divisible by 9.
-